﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class View_addJob : System.Web.UI.Page
{
    AccessDAO dao = new AccessDAO();
    protected void Page_Load(object sender, EventArgs e)
    {
        IsAdmin.Admin();
        this.btnSubmit.Attributes.Add("onclick", "javascript:succShow();");
        if (!Page.IsPostBack)
        {
            this.DateTimePicker1.Text = DateTime.Now.ToString();
            this.txtNumber.Text = "1";
            this.DateTimePicker2.Text = "长期招聘";
            this.txtSalary.Text = "面议";
        }
    }
    //添加
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        string jobName = this.txtJobName.Text;
        string type = this.drpType.SelectedValue.ToString();
        string salary = this.txtSalary.Text;
        int number =Convert.ToInt32(this.txtNumber.Text);
        string diploma = this.drpDiploma.SelectedValue.ToString();
        string sex = this.drpSex.SelectedValue.ToString();
        //string beginTime = this.txtBegintime.Text;
        //string stopTime = this.txtStoptime.Text;
        //string request = this.FreeTextBox1.Text;
        DateTime tt = Convert.ToDateTime(this.DateTimePicker1.Text);
        string beginTime =tt.ToShortDateString() ;
        string stopTime ="";
        string time = this.DateTimePicker2.Text;
        if (time.Equals("长期招聘"))
        {
            stopTime = time;
        }
        else
        {
            DateTime tt1 = Convert.ToDateTime(this.DateTimePicker2.Text);
            stopTime = tt1.ToShortDateString();
        }

        
        string request = this.FCKeditor1.Value;

        string sql = "insert into jobInfo(jobName,jobType,jobSalary,jobNumber,jobDiploma,jobSex,jobbeginTime,jobStopTime,jobrequest) values('"+jobName+
            "','"+type+"','"+salary+"',"+number+",'"+diploma+"','"+sex+"','"+beginTime+"','"+stopTime+"','"+request+"')";
        if (!jobName.Equals(""))
        {
            if (dao.getComm(sql) != 0)
            { 
                Server.Transfer("jobMessage.aspx");
            }
            else
            { 
                RegisterStartupScript("check", "<script language='javascript'>alert('添加失败');</script>");
            }
        }
        else
        {
            RegisterStartupScript("check", "<script language='javascript'>alert('请填写完整');</script>");
        }
    }
    protected void btnClose_Click(object sender, EventArgs e)
    {
        Server.Transfer("jobMessage.aspx");
    }
}
